var patientindex = ['姓名：', '性别：', '年龄：', '序号：']
    var patient = [{
        p_id: 000000,
        p_name: '张某某',
        p_sex: '男',
        p_age: '18',
        p_index: '037',
        p_img: 'img/矩形 110.png'
    }, {
        p_id: 000000,
        p_name: '张某某',
        p_sex: '男',
        p_age: '18',
        p_index: '037',
        p_img: 'img/矩形 110.png'
    }, {
        p_id: 000000,
        p_name: '张某某',
        p_sex: '男',
        p_age: '18',
        p_index: '037',
        p_img: 'img/矩形 110.png'
    }, {
        p_id: 000000,
        p_name: '张某某',
        p_sex: '男',
        p_age: '18',
        p_index: '037',
        p_img: 'img/矩形 110.png'
    }, {
        p_id: 000000,
        p_name: '张某某',
        p_sex: '男',
        p_age: '18',
        p_index: '037',
        p_img: 'img/矩形 110.png'
    }, {
        p_id: 000000,
        p_name: '张某某',
        p_sex: '男',
        p_age: '18',
        p_index: '037',
        p_img: 'img/矩形 110.png'
    }, {
        p_id: 000000,
        p_name: '张某某',
        p_sex: '男',
        p_age: '18',
        p_index: '037',
        p_img: 'img/矩形 110.png'
    }, {
        p_id: 000000,
        p_name: '张某某',
        p_sex: '男',
        p_age: '18',
        p_index: '037',
        p_img: 'img/矩形 110.png'
    }, {
        p_id: 000000,
        p_name: '张某某',
        p_sex: '男',
        p_age: '18',
        p_index: '037',
        p_img: 'img/矩形 110.png'
    }, {
        p_id: 000000,
        p_name: '张某某',
        p_sex: '男',
        p_age: '18',
        p_index: '037',
        p_img: 'img/矩形 110.png'
    }, {
        p_id: 000000,
        p_name: '张某某',
        p_sex: '男',
        p_age: '18',
        p_index: '037',
        p_img: 'img/矩形 110.png'
    }, {
        p_id: 000000,
        p_name: '张某某',
        p_sex: '男',
        p_age: '18',
        p_index: '037',
        p_img: 'img/矩形 110.png'
    }, {
        p_id: 000000,
        p_name: '张某某',
        p_sex: '男',
        p_age: '18',
        p_index: '037',
        p_img: 'img/矩形 110.png'
    }, {
        p_id: 000000,
        p_name: '张某某',
        p_sex: '男',
        p_age: '18',
        p_index: '037',
        p_img: 'img/矩形 110.png'
    }, {
        p_id: 000000,
        p_name: '张某某',
        p_sex: '男',
        p_age: '18',
        p_index: '037',
        p_img: 'img/矩形 110.png'
    },]
    var omain = document.getElementsByTagName('main')[0];

    for (var i = 0; i < patient.length; i++) {
        omain.innerHTML += '<div class="cell clear"><img src="' + patient[i].p_img + '" alt=""><div class="cell_f"><p>' + patientindex[0] + '<span>' + patient[i].p_name + '</span></p><p>' + patientindex[1] + '<span>' + patient[i].p_sex + '</span></p><p>' + patientindex[2] + '<span>' + patient[i].p_age + '</span></p><p>' + patientindex[3] + '<span>' + patient[i].p_index + '</span></p><p><a href="cases_list.html"><i class="fa fa-eye"></a></i>&nbsp;&nbsp;<a href="case_modification.html"><i class="fa fa-pencil"></i></a>&nbsp;&nbsp;<i class="fa fa-trash"></i></p></div></div>'
    }
    var ofooter = document.getElementsByTagName('footer')[0];
    var del = ofooter.getElementsByTagName('p');
    var odiv = document.getElementsByClassName('cell');
    var onOff = true;
    del[0].onclick = function () {
        if (onOff) {
            onOff = false;
            for (var i = 0; i < odiv.length; i++) {
                odiv[i].style.border = '2px solid #cccccc';
                odiv[i].onclick = function () {
                    this.style.border = '2px solid red';
                    del[1].onclick = function () {
                        for (var i = 0; i < odiv.length; i++) {
                            if (odiv[i].style.border == '2px solid red') {
                                odiv[i].remove();
                                i--;
                            }
                        }
                    }
                }
            }
        }else{
            onOff = true;
            for (var i = 0; i < odiv.length; i++){
                odiv[i].style.border = '2px solid rgba(255, 255, 255, 0)';
                odiv[i].onclick ='';
            }
        }
    }

    var oi = document.getElementsByClassName('fa fa-trash');
    for(var i = 0; i < odiv.length; i++){
        oi[i].onclick = function(){
                this.parentNode.parentNode.parentNode.remove();
            }
    }
    

    